package com.web.netty.domain;

import java.io.Serializable;
import java.util.Arrays;

/**
 * @Author: wws
 * describe:
 */
public class DataUpPayload implements Serializable {
    private byte type;
    private byte[] deviceAddr;
    private byte FCtrl;
    private byte[] FCnt;
    private byte[] payload;
    private byte[] mic;

    public DataUpPayload() {
    }

    public DataUpPayload(byte[] data) {
        this.type = data[0];
        this.deviceAddr = Arrays.copyOfRange(data, 1, 5);
        this.FCtrl =  data[5];
        this.FCnt =  Arrays.copyOfRange(data, 6, 8);
        this.payload =  Arrays.copyOfRange(data, 8, data.length-4);
        this.mic = Arrays.copyOfRange(data, data.length-4, data.length);
    }

    public DataUpPayload(byte type, byte[] deviceAddr, byte FCtrl, byte[] FCnt, byte[] payload, byte[] mic) {
        this.type = type;
        this.deviceAddr = deviceAddr;
        this.FCtrl = FCtrl;
        this.FCnt = FCnt;
        this.payload = payload;
        this.mic = mic;
    }

    public byte getType() {
        return type;
    }

    public void setType(byte type) {
        this.type = type;
    }

    public byte[] getDeviceAddr() {
        return deviceAddr;
    }

    public void setDeviceAddr(byte[] deviceAddr) {
        this.deviceAddr = deviceAddr;
    }

    public byte getFCtrl() {
        return FCtrl;
    }

    public void setFCtrl(byte FCtrl) {
        this.FCtrl = FCtrl;
    }

    public byte[] getFCnt() {
        return FCnt;
    }

    public void setFCnt(byte[] FCnt) {
        this.FCnt = FCnt;
    }

    public byte[] getPayload() {
        return payload;
    }

    public void setPayload(byte[] payload) {
        this.payload = payload;
    }

    public byte[] getMic() {
        return mic;
    }

    public void setMic(byte[] mic) {
        this.mic = mic;
    }

    @Override
    public String toString() {
        return "DataUpPayload{" +
                "type=" + type +
                ", deviceAddr=" + Arrays.toString(deviceAddr) +
                ", FCtrl=" + FCtrl +
                ", FCnt=" + Arrays.toString(FCnt) +
                ", payload=" + Arrays.toString(payload) +
                ", mic=" + Arrays.toString(mic) +
                '}';
    }
}
